//
//  HWMembersView.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/9/5.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWMembersView.h"

@interface HWMembersView()

@property(strong,nonatomic) NSArray *dataArra;
@property(strong,nonatomic) NSArray *huiyuanArr;
@property(strong,nonatomic) NSMutableArray *cunchuLabelMuArr;

@end

@implementation HWMembersView

-(instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        // 设置UI
        [self setUpUI];
        
        
        
    }
    
    return  self;
    
}

- (void)setUpUI {
    
    
    
    self.dataArra = @[@"我的积分",@"绑币",@"平台币"];
    self.huiyuanArr = @[@"明细",@"明细",@"充值"];
    
    self.cunchuLabelMuArr = [[NSMutableArray alloc]init];
    
    CGFloat jianju = (kScreenW -30 - 3*80)/4;
    for (int i = 0; i < 3 ; i++) {
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(jianju+jianju*i+80*i, 10, 80, 80)];
      //  view.backgroundColor = [UIColor redColor];
        [self addSubview:view];
        
        UILabel *shulianlabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 8, 80, 13)];
        shulianlabel.textColor =RGB(102, 102, 102);
        shulianlabel.text = self.dataArra[i];
        //  shulianlabel.backgroundColor = [UIColor orangeColor];
        shulianlabel.font = [UIFont systemFontOfSize:13];
        shulianlabel.textAlignment = NSTextAlignmentCenter;
        [view addSubview:shulianlabel];
        
        
        UILabel *jingeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 11+shulianlabel.bottom, 80, 12)];
        jingeLabel.textColor =RGB(27, 27, 27);
        jingeLabel.text = @"0";
        [self.cunchuLabelMuArr addObject:jingeLabel];
        
        //  shulianlabel.backgroundColor = [UIColor orangeColor];
        jingeLabel.font = [UIFont systemFontOfSize:12];
        jingeLabel.textAlignment = NSTextAlignmentCenter;
        [view addSubview:jingeLabel];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(7, jingeLabel.bottom+11, 65, 20);
       //  [button setBackgroundImage:[UIImage imageNamed:@"personal_b"] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:11];
        button.tag = i;
        [button setTitle:self.huiyuanArr[i] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(buttonTap:) forControlEvents:UIControlEventTouchUpInside];
        button.layer.cornerRadius = 4;
        button.layer.masksToBounds = YES;
        
        button.backgroundColor =  QCchunseshensetupian;
        
        
        [view addSubview:button];

    }
    
    
    
    
    
    
}


// 
- (void)buttonTap:(UIButton *)sender {
    
    
    NSInteger tag = sender.tag;
    
    [self.delegate HWMembersViewXuZhongTap:tag];
    
    
}

-(void)setDataDic:(NSDictionary *)dataDic {
    
    _dataDic = dataDic;
    
    
  
    NSString *charge_points = dataDic[@"charge_points"];
    NSString *bind = dataDic[@"bind"];
    NSString *coin = dataDic[@"coin"];
    if (charge_points == nil || bind== nil || coin == nil) {
        return;
    }
    
    
    NSArray *arr = @[dataDic[@"charge_points"],dataDic[@"bind"],dataDic[@"coin"]];
    for (int i = 0; i < self.cunchuLabelMuArr.count; i++) {

        UILabel *labe = self.cunchuLabelMuArr[i];
        labe.text = arr[i];
        
        
    }
    
    
    
}


-(void)setWeidengluoArr:(NSMutableArray *)weidengluoArr {
    
    _weidengluoArr = weidengluoArr;
    
    for (int i = 0; i < self.cunchuLabelMuArr.count; i++) {

           UILabel *labe = self.cunchuLabelMuArr[i];
           labe.text = weidengluoArr[i];
           
           
       }
    
}





@end
